/*
 * Copyright 2010 Gaurav Saxena
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.gwtstructs.gwt.client;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DeckPanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLTable.Cell;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.HorizontalSplitPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.gwtstructs.gwt.client.test.MyVerticalPanel;
import com.gwtstructs.gwt.client.widgets.autocompleterTextbox.AutoCompleterTextBox;
import com.gwtstructs.gwt.client.widgets.autocompleterTextbox.AutoCompleterTextBox.PanelPosition;
import com.gwtstructs.gwt.client.widgets.autocompleterTextbox.CustomSuggestionAutoCompleterTextBox;
import com.gwtstructs.gwt.client.widgets.autocompleterTextbox.DelimeterEnabledCustomSuggestionAutoCompleterTextBox;
import com.gwtstructs.gwt.client.widgets.autocompleterTextbox.DelimiterEnabledAutocompleterTextBox;
import com.gwtstructs.gwt.client.widgets.autocompleterTextbox.ICustomSuggestion;
import com.gwtstructs.gwt.client.widgets.eventbus.EnhancedGwtEvent;
import com.gwtstructs.gwt.client.widgets.eventbus.EnhancedGwtEventHandler;
import com.gwtstructs.gwt.client.widgets.eventbus.Publisher;
import com.gwtstructs.gwt.client.widgets.eventbus.Subscriber;
import com.gwtstructs.gwt.client.widgets.jsBridge.JsBridgable;
import com.gwtstructs.gwt.client.widgets.list.BulletListPanel;
import com.gwtstructs.gwt.client.widgets.list.NumberedListPanel;
import com.gwtstructs.gwt.client.widgets.list.NumberedListPanel.NUMBER_STYLE_TYPE;
import com.gwtstructs.gwt.client.widgets.multicolumnlistbox.ListBoxItem;
import com.gwtstructs.gwt.client.widgets.multicolumnlistbox.MultiColumnListBox;
import com.gwtstructs.gwt.client.widgets.singleselectlistbox.HtmlEnabledListBox;
import com.gwtstructs.gwt.client.widgets.stylesheets.CssImpl;
import com.gwtstructs.gwt.shared.jcTree.ArrayListTree;
import com.gwtstructs.gwt.shared.jcTree.NodeNotFoundException;
import com.gwtstructs.gwt.shared.jcTree.Tree;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class GwtStructs implements EntryPoint {
	private static int labelNumber = 0;
	//private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
	/**
	 * This is the entry point method.
	 */
	@SuppressWarnings("deprecation")
	public void onModuleLoad() {
		HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(/*new HorizontalSplitPanel.Resources() {
			@Override
			public ImageResource horizontalSplitPanelThumb() {
				return new ImageResource() {
				
					@Override
					public String getName() {
						return "none";
					}
					@Override
					public boolean isAnimated() {
						return false;
					}
					@Override
					public int getWidth() {
						return 1;
					}
					@Override
					public String getURL() {
						return "none.jpg";
					}
					@Override
					public int getTop() {
						return 0;
					}
					@Override
					public int getLeft() {
						return 0;
					}
					@Override
					public int getHeight() {
						return 0;
					}
					@Override
					public SafeUri getSafeUri() {
						return null;
					}
				};
			}
		}*/);
		RootPanel.get().add(splitPanel);
		splitPanel.setPixelSize(1150, 600);
		DOM.setStyleAttribute(splitPanel.getElement(), "marginLeft", "10px");
		VerticalPanel indexPanel = new VerticalPanel();
		indexPanel.setWidth("100%");
		DOM.setStyleAttribute(indexPanel.getElement(), "overflow", "hidden");
		splitPanel.setLeftWidget(indexPanel);
		splitPanel.setSplitPosition("200px");
		Label heading = new Label("GWT Structs Widgets");
		heading.setWidth("100%");
		heading.setHeight("20px");
		heading.setStyleName("gwtstructs-heading");
		indexPanel.add(heading);
		final VerticalPanel widgetsPanel = new VerticalPanel();
		indexPanel.add(widgetsPanel);
		
		final DeckPanel deckPanel = new DeckPanel();
		splitPanel.setRightWidget(deckPanel);
		deckPanel.setSize("800px", "100%");
		deckPanel.add(getDeck1());
		deckPanel.add(getDeck2());
		deckPanel.add(getDeck3());
		deckPanel.add(getDeck4());
		deckPanel.add(getDeck5());
		deckPanel.add(getDeck6());
		deckPanel.add(getDeck7());
		deckPanel.add(getDeck8());
		deckPanel.add(getDeck9());
		deckPanel.showWidget(0);
		
		widgetsPanel.setStyleName("gwtstructs-widgetsPanel");
		final Label autocomleter = new Label("Autocompleter Textbox");
		widgetsPanel.add(autocomleter);
		highlight(widgetsPanel, autocomleter);
		autocomleter.setStyleName("gwtstructs-IndexPanel-indexItem");
		autocomleter.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				highlight(widgetsPanel, autocomleter);
				deckPanel.showWidget(0);
			}
			
		});
		widgetsPanel.setCellHeight(autocomleter, "30px");
		final Label multicolumn = new Label("Multi-column Selection Box");
		widgetsPanel.add(multicolumn);
		multicolumn.setStyleName("gwtstructs-IndexPanel-indexItem");
		multicolumn.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				highlight(widgetsPanel, multicolumn);
				deckPanel.showWidget(1);
			}
		});
		final Label htmlMulticolumn = new Label("Multi-column Selection Box - html options");
		widgetsPanel.add(htmlMulticolumn);
		htmlMulticolumn.setStyleName("gwtstructs-IndexPanel-indexItem");
		htmlMulticolumn.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				highlight(widgetsPanel, htmlMulticolumn);
				deckPanel.showWidget(2);
			}
		});
		final Label htmlSingleSelection = new Label("Single Selection Box - html options");
		widgetsPanel.add(htmlSingleSelection);
		htmlSingleSelection.setStyleName("gwtstructs-IndexPanel-indexItem");
		htmlSingleSelection.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				highlight(widgetsPanel, htmlSingleSelection);
				deckPanel.showWidget(3);
			}
		});
		final Label eventbus = new Label("Eventbus");
		widgetsPanel.add(eventbus);
		eventbus.setStyleName("gwtstructs-IndexPanel-indexItem");
		eventbus.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				highlight(widgetsPanel, eventbus);
				deckPanel.showWidget(4);
			}
		});
		final Label jsBridge = new Label("JsBridge");
		widgetsPanel.add(jsBridge);
		jsBridge.setStyleName("gwtstructs-IndexPanel-indexItem");
		jsBridge.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				highlight(widgetsPanel, jsBridge);
				deckPanel.showWidget(5);
			}
		});
		final Label gwtCss = new Label("Gwt Css");
		widgetsPanel.add(gwtCss);
		gwtCss.setStyleName("gwtstructs-IndexPanel-indexItem");
		gwtCss.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				highlight(widgetsPanel, gwtCss);
				deckPanel.showWidget(6);
			}
		});
		final Label jcTree = new Label("JC Tree");
		widgetsPanel.add(jcTree);
		jcTree.setStyleName("gwtstructs-IndexPanel-indexItem");
		jcTree.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				highlight(widgetsPanel, jcTree);
				deckPanel.showWidget(7);
			}
		});
		final Label numberedLists = new Label("Numbered and Bulleted Lists");
		widgetsPanel.add(numberedLists);
		numberedLists.setStyleName("gwtstructs-IndexPanel-indexItem");
		numberedLists.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				highlight(widgetsPanel, numberedLists);
				deckPanel.showWidget(8);
			}
		});
	}
	private void highlight(VerticalPanel widgetsPanel, Label autocomleter) {
		for(int i = 0; i < widgetsPanel.getWidgetCount(); i++)
			widgetsPanel.getWidget(i).removeStyleName("gwtstructs-indexPanel-selected");
		autocomleter.addStyleName("gwtstructs-indexPanel-selected");
	}
	private VerticalPanel getDeck1()
	{
		final List<String> list = new ArrayList<String>();
		list.add("Gaurav");
		list.add("Gautam");
		list.add("Saurabh");
		list.add("Sachin");
		list.add("Mugdha");
		list.add("Mini");
		list.add("Sarita");
		list.add("Ravi");
		list.add("Gaurav");
		list.add("Gautam");
		list.add("Saurabh");
		list.add("Sachin");
		list.add("Mugdha");
		list.add("Mini");
		list.add("Sarita");
		list.add("Ravi");
		list.add("Gaurav");
		list.add("Gautam");
		list.add("Saurabh");
		list.add("Sachin");
		list.add("Mugdha");
		list.add("Mini");
		list.add("Sarita");
		list.add("Ravi");
		VerticalPanel vp = new VerticalPanel();
        vp.setWidth("99%");
        DOM.setStyleAttribute(vp.getElement(), "paddingLeft", "50px");
        HTML autocompleterTextBoxLabel = new HTML("Autocompleter Text box - Click on the textbox to show suggestions");
        DOM.setStyleAttribute(autocompleterTextBoxLabel.getElement(), "fontSize", "20px");
        vp.add(autocompleterTextBoxLabel);
        HorizontalPanel hp1 = new HorizontalPanel();
        vp.add(hp1);
        hp1.add(new Label("Suggestions on the Left"));
        final AutoCompleterTextBox nameField1 = new AutoCompleterTextBox(list, false, false, PanelPosition.LEFT);
        hp1.add(nameField1);
        hp1.setCellWidth(nameField1, "200px");
        DOM.setStyleAttribute(nameField1.getElement(), "marginBottom", "50px");
        hp1.setCellWidth(hp1.getWidget(0), "200px");
        
        hp1.add(new Label("Suggestions on the Right"));
        AutoCompleterTextBox nameField2 = new AutoCompleterTextBox(list, false, false, PanelPosition.RIGHT);
        hp1.add(nameField2);
        DOM.setStyleAttribute(nameField2.getElement(), "marginBottom", "50px");
        hp1.setCellWidth(hp1.getWidget(2), "200px");
        
        HorizontalPanel hp2 = new HorizontalPanel();
        vp.add(hp2);
        hp2.add(new Label("Suggestions at the Bottom"));
        AutoCompleterTextBox nameField3 = new AutoCompleterTextBox(list, false, false, PanelPosition.BOTTOM);
        nameField3.setSuggestionWidth(400);
        hp2.add(nameField3);
        hp2.setCellWidth(nameField3, "200px");
        DOM.setStyleAttribute(nameField3.getElement(), "marginBottom", "50px");
        hp2.setCellWidth(hp2.getWidget(0), "200px");
        
        hp2.add(new Label("Suggestions at the Top"));
        AutoCompleterTextBox nameField4 = new AutoCompleterTextBox(list, false, false, PanelPosition.TOP);
        hp2.add(nameField4);
        DOM.setStyleAttribute(nameField4.getElement(), "marginBottom", "50px");
        hp2.setCellWidth(hp2.getWidget(2), "200px");
        
        HorizontalPanel hp3 = new HorizontalPanel();
        vp.add(hp3);
        hp3.add(new Label("Custom HTML Suggestions"));
        List<ICustomSuggestion> customSuggestions = new ArrayList<ICustomSuggestion>();
        customSuggestions.add(new CustomSuggestionImpl("Google","<img src='http://www.google.com/favicon.ico'>Google"));
        customSuggestions.add(new CustomSuggestionImpl("Google","<img src='http://www.google.com/favicon.ico'>Google"));
        customSuggestions.add(new CustomSuggestionImpl("Yahoo","<img src='http://www.yahoo.com/favicon.ico'>Yahoo"));
        customSuggestions.add(new CustomSuggestionImpl("Yahoo","<img src='http://www.yahoo.com/favicon.ico'>Yahoo"));
        AutoCompleterTextBox nameField5 = new CustomSuggestionAutoCompleterTextBox(customSuggestions, false, false, PanelPosition.TOP);
        hp3.add(nameField5);
        hp3.setCellWidth(nameField5, "200px");
        DOM.setStyleAttribute(nameField5.getElement(), "marginBottom", "50px");
        hp3.setCellWidth(hp3.getWidget(0), "200px");


        hp3.add(new Label("Suggestions for names delimited by comma"));
        final AutoCompleterTextBox nameField6 = new DelimiterEnabledAutocompleterTextBox(list, false, false, PanelPosition.BOTTOM, ",");
        hp3.add(nameField6);
        DOM.setStyleAttribute(nameField6.getElement(), "marginBottom", "50px");
        hp3.setCellWidth(hp3.getWidget(2), "200px");
        
        HorizontalPanel hp4 = new HorizontalPanel();
        vp.add(hp4);
        hp4.add(new Label("Custom HTML Suggestions for names delimited by comma"));
        AutoCompleterTextBox nameField7 = new DelimeterEnabledCustomSuggestionAutoCompleterTextBox(customSuggestions, false, false, PanelPosition.TOP,",");
        hp4.add(nameField7);
        hp4.setCellWidth(nameField7, "200px");
        DOM.setStyleAttribute(nameField7.getElement(), "marginBottom", "50px");
        hp4.setCellWidth(hp4.getWidget(0), "200px");
        
        return vp;
	}
	private VerticalPanel getDeck2()
	{
		List<ListBoxItem<String>> listBoxItems = new ArrayList<ListBoxItem<String>>();
		listBoxItems.add(new ListBoxItem<String>("Cat is an animal","1", true));
		listBoxItems.add(new ListBoxItem<String>("Dog is an animal","2"));
		listBoxItems.add(new ListBoxItem<String>("Tiger is an animal","3", true));
		listBoxItems.add(new ListBoxItem<String>("Bull is an animal","4"));
		listBoxItems.add(new ListBoxItem<String>("Cow is an animal","5"));
		listBoxItems.add(new ListBoxItem<String>("Sheep is an animal","6"));
		listBoxItems.add(new ListBoxItem<String>("Giraffe is an animal","7"));
		listBoxItems.add(new ListBoxItem<String>("Zebra is an animal","8"));
		listBoxItems.add(new ListBoxItem<String>("Lion is an animal","9"));
		VerticalPanel vp = new VerticalPanel();
		DOM.setStyleAttribute(vp.getElement(), "paddingLeft", "50px");
		HTML multiColumnTextBoxLabel = new HTML("Multi Column Selection Box");
		DOM.setStyleAttribute(multiColumnTextBoxLabel.getElement(), "fontSize", "20px");
		vp.add(multiColumnTextBoxLabel);
		final MultiColumnListBox<String> ml = new MultiColumnListBox<String>(listBoxItems, 4);
		vp.add(ml);
		//ml.setMultiSelect(false);
		ml.setWidth("200px");
		ml.setOptionTableWidth(500);
		final VerticalPanel selectedItems = new VerticalPanel();
		vp.add(selectedItems);
		selectedItems.setHeight("300px");
		ml.addChangeHandler(new ChangeHandler(){
			@Override
			public void onChange(ChangeEvent event) {
				selectedItems.clear();
				for(int i = 0; i < ml.getListBoxItems().size(); i++)
					if(ml.getListBoxItems().get(i).isSelected())
						selectedItems.add(new HTML("Value: " + ml.getListBoxItems().get(i).getValue() + 
								", Text:" + ml.getListBoxItems().get(i).getDisplayNameHtml()));
			}
		});
		return vp;
	}
	private Widget getDeck3() {
		List<ListBoxItem<String>> listBoxItems = new ArrayList<ListBoxItem<String>>();
		listBoxItems.add(new ListBoxItem<String>("<img src='http://google.com/favicon.ico'>Google","1", true));
		listBoxItems.add(new ListBoxItem<String>("<img src='http://yahoo.com/favicon.ico'>Yahoo","2"));
		listBoxItems.add(new ListBoxItem<String>("<img src='http://msn.com/favicon.ico'>Msn","3", true));
		listBoxItems.add(new ListBoxItem<String>("<img src='http://aol.com/favicon.ico'>Aol","4"));
		listBoxItems.add(new ListBoxItem<String>("<img src='http://ask.com/favicon.ico'>Ask Jeeves","5"));
		listBoxItems.add(new ListBoxItem<String>("<img src='http://mahalo.com/favicon.ico'>Mahalo","6"));
		listBoxItems.add(new ListBoxItem<String>("<img src='http://like.com/favicon.ico'>Like","7"));
		listBoxItems.add(new ListBoxItem<String>("<img src='http://guruji.com/favicon.ico'>Guruji","8"));
		listBoxItems.add(new ListBoxItem<String>("<img src='http://baidu.com/favicon.ico'>Baidu","9"));
		VerticalPanel vp = new VerticalPanel();
		DOM.setStyleAttribute(vp.getElement(), "paddingLeft", "50px");
		HTML multiColumnTextBoxLabel = new HTML("Multi Column Selection Box");
		DOM.setStyleAttribute(multiColumnTextBoxLabel.getElement(), "fontSize", "20px");
		vp.add(multiColumnTextBoxLabel);
		final MultiColumnListBox<String> ml = new MultiColumnListBox<String>(listBoxItems, 4);
		vp.add(ml);
		ml.setWidth("400px");
		ml.setOptionTableWidth(400);
		final VerticalPanel selectedItems = new VerticalPanel();
		vp.add(selectedItems);
		selectedItems.setHeight("300px");
		ml.addChangeHandler(new ChangeHandler(){
			@Override
			public void onChange(ChangeEvent event) {
				selectedItems.clear();
				for(int i = 0; i < ml.getListBoxItems().size(); i++)
					if(ml.getListBoxItems().get(i).isSelected())
						selectedItems.add(new HTML("Value: " + ml.getListBoxItems().get(i).getValue() + 
								", Text:" + ml.getListBoxItems().get(i).getDisplayNameHtml()));
			}
		});
		return vp;
	}
	private Widget getDeck4() {
		List<com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>> listBoxItems 
		= new ArrayList<com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>>();
		listBoxItems.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<img src='http://google.com/favicon.ico' style='border-width: 0;'>Google","1", true));
		listBoxItems.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<img src='http://yahoo.com/favicon.ico'>Yahoo","2"));
		listBoxItems.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<img src='http://msn.com/favicon.ico'>Msn","3", true));
		listBoxItems.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<img src='http://aol.com/favicon.ico'>Aol","4"));
		listBoxItems.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<img src='http://ask.com/favicon.ico'>Ask Jeeves","5"));
		listBoxItems.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<img src='http://mahalo.com/favicon.ico'>Mahalo","6"));
		listBoxItems.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<img src='http://like.com/favicon.ico'>Like","7"));
		listBoxItems.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<img src='http://guruji.com/favicon.ico'>Guruji","8"));
		listBoxItems.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<img src='http://baidu.com/favicon.ico'>Baidu","9"));
		VerticalPanel vp = new VerticalPanel();
		DOM.setStyleAttribute(vp.getElement(), "paddingLeft", "50px");
		HTML singleSelectListBox = new HTML("Single Selection Box");
		DOM.setStyleAttribute(singleSelectListBox.getElement(), "fontSize", "20px");
		vp.add(singleSelectListBox);
		HorizontalPanel hp =  new HorizontalPanel();
		vp.add(hp);
		hp.setWidth("100%");
		final HtmlEnabledListBox<String> sl = new HtmlEnabledListBox<String>(listBoxItems);
		hp.add(sl);
		sl.setWidth("150px");
		sl.setDefaultText("Search Engines");
		final VerticalPanel selectedItems = new VerticalPanel();
		vp.add(selectedItems);
		selectedItems.setHeight("300px");
		
		List<com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>> listBoxItems2
		= new ArrayList<com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>>();
		listBoxItems2.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<span style='font-size: 10px'>Font size: 10</span>","10", true));
		listBoxItems2.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<span style='font-size: 12px'>Font size: 12</span>","12"));
		listBoxItems2.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<span style='font-size: 14px'>Font size: 14</span>","14", true));
		listBoxItems2.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<span style='font-size: 16px'>Font size: 16</span>","16"));
		listBoxItems2.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<span style='font-size: 18px'>Font size: 18</span>","18"));
		listBoxItems2.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<span style='font-size: 20px'>Font size: 20</span>","20"));
		listBoxItems2.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<span style='font-size: 22px'>Font size: 22</span>","22"));
		listBoxItems2.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<span style='font-size: 24px'>Font size: 24</span>","24"));
		listBoxItems2.add(new com.gwtstructs.gwt.client.widgets.singleselectlistbox.ListBoxItem<String>("<span style='font-size: 26px'>Font size: 26</span>","26"));
		final HtmlEnabledListBox<String> sl2 = new HtmlEnabledListBox<String>(listBoxItems2);
		hp.add(sl2);
		sl2.setWidth("200px");
		sl2.setDefaultText("Pick Font Size");
		return vp;
	}
	
	private Widget getDeck5()
	{
		VerticalPanel vp = new VerticalPanel();
		DOM.setStyleAttribute(vp.getElement(), "paddingLeft", "50px");
		HTML singleSelectListBox = new HTML("Eventbus Demo ");
		DOM.setStyleAttribute(singleSelectListBox.getElement(), "fontSize", "20px");
		vp.add(singleSelectListBox);
		vp.add(new Label("In all the eventbus demos, data is being passed using Gwt eventbus and not directly from event handler"));
		vp.add(new HTML("&nbsp;"));
		vp.add(new Label("Type a message in textbox on the left and press Button"));
		HorizontalPanel hp = new HorizontalPanel();
		vp.add(hp);
		DOM.setStyleAttribute(hp.getElement(), "width", "100%");
		DOM.setStyleAttribute(hp.getElement(), "height", "100px");
		final TextBox t = new TextBox();
		hp.add(t);
		Button b = new Button("Send Message");
		hp.add(b);
		final TextBox t1 = new TextBox();
		hp.add(t1);
		final Publisher<String> p = new Publisher<String>();
		b.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				p.publish(t.getText(), "com.eventbus.test");
			}});
		Subscriber<String> s = new Subscriber<String>();
		s.addHandler("com.eventbus.test", new EnhancedGwtEventHandler<String>(){

			@Override
			public void onEnhancedGwtEvent(EnhancedGwtEvent<String> e) {
				t1.setText(e.getData());
			}});
		vp.add(new Label("Button press instantiates a label and sends it via eventbus to Vertical Panel on the right"));
		HorizontalPanel hp1 = new HorizontalPanel();
		vp.add(hp1);
		DOM.setStyleAttribute(hp1.getElement(), "width", "100%");
		DOM.setStyleAttribute(hp1.getElement(), "height", "200px");
		Button b1 = new Button("Add Label");
		hp1.add(b1);
		final Publisher<Label> p1 = new Publisher<Label>();
		b1.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				p1.publish(new Label("Label Number: " + labelNumber++), "com.eventbus.test1");
			}});
		final VerticalPanel vpr = new VerticalPanel();
		hp1.add(vpr);
		Subscriber<Label> s1r = new Subscriber<Label>();
		s1r.addHandler("com.eventbus.test1", new EnhancedGwtEventHandler<Label>(){
			@Override
			public void onEnhancedGwtEvent(EnhancedGwtEvent<Label> e) {
				vpr.add(e.getData());
			}});
		return vp;
	}
	private Widget getDeck6() {
		VerticalPanel vp = new VerticalPanel();
		vp.setHeight("500px");
		DOM.setStyleAttribute(vp.getElement(), "paddingLeft", "50px");
		HTML jsBridgeLabel = new HTML("JsBridge Demo ");
		DOM.setStyleAttribute(jsBridgeLabel.getElement(), "fontSize", "20px");
		vp.add(jsBridgeLabel);
		HorizontalPanel hp = new HorizontalPanel();
		vp.add(hp);
		DOM.setStyleAttribute(hp.getElement(), "width", "100%");
		DOM.setStyleAttribute(hp.getElement(), "height", "100px");
		final VerticalPanel myVp = new MyVerticalPanel();
		hp.add(myVp);
		myVp.add(new Label("Child1"));
		myVp.add(new Label("Child2"));
		myVp.add(new Label("Child3"));
		myVp.add(new Label("Child4"));
		DOM.setStyleAttribute(myVp.getElement(), "border", "solid 1px gray");
		myVp.getElement().setId("myVp");
		
		JsBridgable jsBridgable = GWT.create(JsBridgable.class);
		jsBridgable.createBridge(myVp);
		
		vp.add(new Label("Vertical Panel above exposes getWidgetCount method"));
		final TextArea ta = new TextArea();
		ta.setPixelSize(500, 100);
		ta.setText("alert(document.getElementById('myVp').getWidgetCount())");
		vp.add(ta);
		ta.setStyleName("late");
		Button button = new Button("Execute");
		vp.add(button);
		button.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				executeJs(ta.getText());
			}
			private native void executeJs(String text) /*-{
				$wnd.eval(text);
			}-*/;
		});
		return vp;
	}
	private Widget getDeck7() {
		final CssImpl cssImpl = GWT.create(CssImpl.class);
		VerticalPanel vp = new VerticalPanel();
		vp.setHeight("500px");
		DOM.setStyleAttribute(vp.getElement(), "paddingLeft", "50px");
		final HTML gwtCssLabel = new HTML("Gwt Css Demo");
		DOM.setStyleAttribute(gwtCssLabel.getElement(), "fontSize", "20px");
		vp.add(gwtCssLabel);
		final HTML gwtCssDesc = new HTML("Please add css rules to modify the style of the label above");
		DOM.setStyleAttribute(gwtCssDesc.getElement(), "fontSize", "17px");
		vp.add(gwtCssDesc);
		vp.add(new Label("Css Class Name: gwt-css-demo-style"));
		HorizontalPanel hp1 = new HorizontalPanel();
		vp.add(hp1);
		vp.setCellHeight(hp1, "1px");
		hp1.add(new Label("Css Rules"));
		final TextArea cssRules = new TextArea();
		cssRules.setPixelSize(300, 100);
		hp1.add(cssRules);
		cssRules.setValue("color:black;");
		HorizontalPanel buttonHp = new HorizontalPanel();
		vp.add(buttonHp);
		Button getRule = new Button("Alert Rule");
		buttonHp.add(getRule);
		getRule.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				Window.alert(cssImpl.getRule(".gwt-HTML"));
		}});
		Button apply = new Button("Apply Rule");
		buttonHp.add(apply);
		apply.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				cssImpl.addRule(".gwt-HTML", cssRules.getText());
		}});
		Button delete = new Button("Delete Rule");
		buttonHp.add(delete);
		delete.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				cssImpl.deleteRule(".gwt-HTML");
		}});
		HorizontalPanel editRuleHp = new HorizontalPanel();
		vp.add(editRuleHp);
		Label editRuleLabel = new Label("backgroundColor = ");
		editRuleHp.add(editRuleLabel);
		final TextBox editRuleTb = new TextBox();
		editRuleHp.add(editRuleTb);
		editRuleTb.setText("#ffffff");
		Button editRuleButton = new Button("Edit Rule");
		editRuleHp.add(editRuleButton);
		editRuleButton.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				cssImpl.editRule(".gwt-HTML", "backgroundColor", editRuleTb.getText());
			}});
		gwtCssLabel.setStyleName("gwt-css-demo-style");
		return vp;
	}
	private Widget getDeck8() {
		VerticalPanel vp = new VerticalPanel();
		vp.setHeight("500px");
		DOM.setStyleAttribute(vp.getElement(), "paddingLeft", "50px");
		HTML jcTreeBridgeLabel = new HTML("JcTree Demo ");
		DOM.setStyleAttribute(jcTreeBridgeLabel.getElement(), "fontSize", "20px");
		vp.add(jcTreeBridgeLabel);
		final HTML jcTreeInstruction = new HTML("Please click on a button to spawn its new child. The nodes are stored in JC Tree and queried and manipulated to maintain the tree in the memory");
		DOM.setStyleAttribute(jcTreeInstruction.getElement(), "fontSize", "12px");
		vp.add(jcTreeInstruction);
		final Tree<Button> tree = new ArrayListTree<Button>();
		final FlexTable treeTable = new FlexTable();
		vp.add(treeTable);
		treeTable.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				try {
					Cell cellForEvent = treeTable.getCellForEvent(event);
					int col = cellForEvent.getCellIndex();
					int row = cellForEvent.getRowIndex();
					int totalCols = 0;
					for(int i = 0; i < col; i++)
						totalCols += treeTable.getFlexCellFormatter().getColSpan(row, i);
					int addAtColNum = 0;
					if(treeTable.getRowCount() > row + 1) {
						for(int i = 0, columnNumber = 0, cellCount = treeTable.getCellCount(row + 1); i < totalCols; 
						i += treeTable.getFlexCellFormatter().getColSpan(row + 1, columnNumber++)) {
							if(columnNumber < cellCount)
								addAtColNum++;
							else {
								addAtColNum = totalCols - i + addAtColNum;
								break;
							}
						}
					} else
						addAtColNum = totalCols;
					addNodeToTree((Button) treeTable.getWidget(row, col), tree, treeTable, row + 1, addAtColNum + tree.children((Button) treeTable.getWidget(row, col)).size());
					if(tree.children((Button) treeTable.getWidget(row, col)).size() > 1)
						updateColSpanValues((Button) treeTable.getWidget(row, col));
				} catch (NodeNotFoundException e) {
					e.printStackTrace();
				}
			}
			private void updateColSpanValues(Button node) throws NodeNotFoundException {
				if(node != null) {
					DOM.setElementPropertyInt((Element) node.getElement().getParentElement(), "colSpan"
					, DOM.getElementPropertyInt((Element) node.getElement().getParentElement(),"colSpan") + 1);
					updateColSpanValues(tree.parent(node));
				}
			}});
		addNodeToTree(null, tree, treeTable, 0, 0);
		/*Tree<String> serverTree = new ArrayListTree<String>();
		try {
			serverTree.add(null, "0");
			serverTree.add("0","0-1");
			serverTree.add("0","0-2");
		greetingService.sendTree(serverTree, new AsyncCallback<String>() {
			@Override
			public void onFailure(Throwable caught) {
				caught.printStackTrace();
			}
			@Override
			public void onSuccess(String result) {
				System.out.println(result);
			}
		});
		} catch (NodeNotFoundException e) {
			e.printStackTrace();
		}*/
		return vp;
	}
	private void addNodeToTree(Button parent, final Tree<Button> tree, final FlexTable treeTable, final int row, final int col) {
		final Button node = new Button();
		try {
			tree.add(parent, node);
			if(treeTable.getRowCount() > row && treeTable.getCellCount(row) > col && treeTable.getWidget(row, col) != null)
				treeTable.insertCell(row, col);
			treeTable.setWidget(row, col, node);
			if(parent != null)
				node.setText(parent.getText() + "-" + tree.children(parent).size());
			else
				node.setText("0");
			DOM.setStyleAttribute((Element) node.getElement().getParentElement(), "textAlign", "center");
			DOM.setStyleAttribute((Element) node.getElement().getParentElement(), "borderBottom", "solid 1px gray");
			treeTable.getFlexCellFormatter().setColSpan(row, col, 1);
		} catch (NodeNotFoundException e) {
			e.printStackTrace();
		}
	}
	private Widget getDeck9() {
		VerticalPanel vp = new VerticalPanel();
		vp.setHeight("500px");
		DOM.setStyleAttribute(vp.getElement(), "paddingLeft", "50px");
		HTML numberedListLabel = new HTML("Widget List Demo");
		DOM.setStyleAttribute(numberedListLabel.getElement(), "fontSize", "20px");
		vp.add(numberedListLabel);
		NumberedListPanel numberedList = new NumberedListPanel();
		numberedList.add(new Label("Item No. 1"));
		numberedList.add(new Image("http://google.com/favicon.ico"));
		numberedList.insert(new Label("Item No 2"), 1);
		numberedList.remove(1);
		numberedList.setNumberStyleType(NUMBER_STYLE_TYPE.ARMENIAN);
		vp.add(numberedList);
		BulletListPanel bulletListPanel = new BulletListPanel();
		vp.add(bulletListPanel);
		Label label = new Label("Thunderbird");
		DOM.setStyleAttribute(label.getElement(), "marginBottom", "30px");
		bulletListPanel.add(label);
		bulletListPanel.add(new Label("Classic 500"));
		bulletListPanel.insert(new Label("Item No 2"), 1);
		bulletListPanel.remove(1);
		//bulletListPanel.setBulletSize(30);
		//bulletListPanel.setBulletColor("red");
		bulletListPanel.setBulletImageUrl("images/bullet.jpg");
		return vp;
	}
}